package com.byjh.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.byjh.common.annotation.Log;
import com.byjh.common.core.controller.BaseController;
import com.byjh.common.core.domain.AjaxResult;
import com.byjh.common.enums.BusinessType;
import com.byjh.app.domain.DocumentType;
import com.byjh.app.service.IDocumentTypeService;
import com.byjh.common.utils.poi.ExcelUtil;
import com.byjh.common.core.page.TableDataInfo;

/**
 * 文件类型Controller
 * 
 * @author Dhq
 * @date 2025-02-05
 */
@RestController
@RequestMapping("/app/documentType")
public class DocumentTypeController extends BaseController
{
    @Autowired
    private IDocumentTypeService documentTypeService;

    /**
     * 查询文件类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DocumentType documentType)
    {
        startPage();
        List<DocumentType> list = documentTypeService.selectDocumentTypeList(documentType);
        return getDataTable(list);
    }


    /**
     * 获取文件类型详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(documentTypeService.selectDocumentTypeById(id));
    }

    /**
     * 新增文件类型
     */
    @Log(title = "文件类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocumentType documentType)
    {
        return toAjax(documentTypeService.insertDocumentType(documentType));
    }

    /**
     * 修改文件类型
     */
    @Log(title = "文件类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocumentType documentType)
    {
        return toAjax(documentTypeService.updateDocumentType(documentType));
    }

    /**
     * 删除文件类型
     */
    @Log(title = "文件类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(documentTypeService.deleteDocumentTypeByIds(ids));
    }
}
